//
//  ProductEntity.m
//  NewApp
//
//  Created by xueyan liu on 6/23/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "ProductData.h"

/*
 * ShopCar Entity
 */
@implementation ShopCarEntity

@synthesize ID;
@synthesize img;
@synthesize info;
@synthesize item_no;
@synthesize item_name;
@synthesize sprice;
@synthesize price;
@synthesize num;

-(id)initWithDictionary:(NSDictionary *)dic{
    
    if (self = [super init]) {
        self.ID = [dic objectForKey:@"id"];
        self.img = [NSURL URLWithString:[dic objectForKey:@"img"]];
        self.info = [dic objectForKey:@"info"];
        self.item_name = [dic objectForKey:@"item_name"];
        self.item_no = [dic objectForKey:@"item_no"];
        self.num = [dic objectForKey:@"num"];
        self.price = [dic objectForKey:@"price"];
        self.sprice = [dic objectForKey:@"sprice"];
    }
    
    return self;
    
}

@end

/*
 * Product Entity
 */
@implementation ProductEntity

@synthesize  ID;
@synthesize  title;
@synthesize  info;
@synthesize  sd;
@synthesize  img;

-(id)initWithID:(NSString *)_ID 
                       title:(NSString *)_title 
                        info:(NSString *)_info
                          sd:(NSString *)_sd 
                         img:(NSURL *)_img{
    [super init];
    
    self.ID = _ID;
    self.title = _title;
    self.info = _info;
    self.sd = _sd;
    self.img = _img;
    
    return self;
}

-(id)initWithDictionary:(NSDictionary *)dic{

    if (self = [super init]) {
        self.ID = [dic objectForKey:@"id"];
        self.img = [NSURL URLWithString:[dic objectForKey:@"img"]];
        self.title = [dic objectForKey:@"title"];
        self.info = [dic objectForKey:@"info"];
        self.sd = [dic objectForKey:@"sd"];
    }
    
    return self;

}

@end

/*
 * Product Data
 */
@implementation ProductData

@synthesize topTitle;
@synthesize count;
@synthesize style;
@synthesize data;

-(id) initWithTitle:(NSString *)_topTitle 
                         count:(NSString *)_count
                         style:(NSString *)_style
                          data:(NSArray *)_data{
    [super init];

    self.topTitle = _topTitle;
    self.count = _count;
    self.style = _style;
    self.data = [[NSMutableArray alloc] initWithArray:_data];
    
    return self;
}

@end

@implementation MyOrderEntity

@synthesize ID;
@synthesize date;
@synthesize state;
@synthesize payway;
@synthesize phone;
@synthesize address;

- (id)initWithDictionary:(NSDictionary *)dict {

    self = [super init];
    if(self != nil && dict != nil) {
    
        self.ID = [dict objectForKey:@"id"];
        self.date = [dict objectForKey:@"sd"];
        self.state = [dict objectForKey:@"state"];
        self.payway = [dict objectForKey:@"payway"];
        self.phone = [dict objectForKey:@"phone"];
        self.address = [dict objectForKey:@"address"];
    }
    
    return self;
}

- (void)dealloc {
    
    [ID release];
    [date release];
    [state release];
    [payway release];
    [phone release];
    [address release];

    [super dealloc];
}

@end

@implementation MyOrderViewEntity

@synthesize ID;
@synthesize Item_name;
@synthesize Item_no;
@synthesize num;
@synthesize sprice;
@synthesize img;

- (id)initWithDictionary:(NSDictionary *)dict {

    self = [super init];
    if(self != nil && dict != nil) {
    
        self.ID = [dict objectForKey:@"id"];
        self.Item_name = [dict objectForKey:@"item_name"];
        self.Item_no = [dict objectForKey:@"item_no"];
        self.num = [dict objectForKey:@"num"];
        self.sprice = [dict objectForKey:@"sprice"];
        self.img = [dict objectForKey:@"img"];
    }
    
    return self;
}

- (void)dealloc {

    [ID release];
    [Item_name release];
    [Item_no release];
    [num release];
    [sprice release];
    [img release];
    
    [super dealloc];
}

@end
